package com.kaaction.modules.crab.api;

import java.io.UnsupportedEncodingException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.dom4j.DocumentException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.kaaction.common.web.BaseController;
import com.kaaction.modules.crab.service.CouponDetailService;
import com.kaaction.modules.crab.service.CrabProductService;

@Controller
@RequestMapping(value = "/api/v1/crabProductApi")
public class CrabProductApiController  extends BaseController{
	
	@Autowired
	CrabProductService crabProductService;
	
	@Autowired
	CouponDetailService couponDetailService;
	
	/**
	 * 推荐商品信息以及卡号信息
	 * 
	 * @param request
	 * @param response
	 * @throws UnsupportedEncodingException
	 * @throws DocumentException
	 */
	@RequestMapping(value = "/selRecommendProduct")
	public void selRecommendProduct(HttpServletRequest request, HttpServletResponse response)
			throws UnsupportedEncodingException, DocumentException {
		String cardNum = request.getParameter("cardNum");
		String password = request.getParameter("password");
		super.writeAjaxResponse(response,couponDetailService.selCardNumMsg(cardNum,password));
	}
	
	/**
	 * 推荐商品
	 * 
	 * @param request
	 * @param response
	 * @throws UnsupportedEncodingException
	 * @throws DocumentException
	 */
	@RequestMapping(value = "/getRecommendProduct")
	public void getRecommendProduct(HttpServletRequest request, HttpServletResponse response)
			throws UnsupportedEncodingException, DocumentException {
		super.writeAjaxResponse(response,crabProductService.selRecommendProduct());
	}

}
